﻿using JilyGameFramework.Manager;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace JilyGameFramework.Controls
{
    public class Button : Control
    {

        private Texture2D UnPressTexture;
        private string unPressImage;
        public string UnPressImage
        {
            get { return unPressImage; }
            set { unPressImage = value; }
        }

        public Button(Rectangle bounds, string pressimage, string unpressimage)
            : base(bounds, pressimage)
        {
            this.UnPressImage = unpressimage;
        }

        public override void LoadContent()
        {
            base.LoadContent();

            if (!string.IsNullOrWhiteSpace(this.UnPressImage))
            {
                UnPressTexture = ScreenManager.Content.Load<Texture2D>(this.UnPressImage);
            }
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        public override void DrawView()
        {
            if (this.IsPress)
            {
                base.DrawView();
            }
            else
            {
                ScreenManager.SpriteBatch.Draw(UnPressTexture, this.Bounds, Color.White);
            }
        }

    }
}
